@page "/Cluster/Metrics"
@inherits BlazorApp.Pages.Common.PageBase

<div Style="margin: 50px">
    <p>
        <Alert Type="@AlertType.Success">
            @L["Metrics data from /metrics endpoint"] , @L["Refresh every 10 seconds"].
        </Alert>
    </p>
</div>

<Tabs Style="margin: 50px" DefaultActiveKey="Etcd" Type="@TabType.Card" Size="@TabSize.Large">

    @if (AllMetrics != null)
    {
        <TabPane Key="Etcd" Tab=@L["Etcd"]>

            <MetricsCounterGaugeSumView AllMetrics="@AllMetrics"
                                        MetricName="apiserver_storage_size_bytes"
                                        Title=@L["Storage Size"]
                                        Unit="bytes"
                                        MultipleGroupBy=@(new List<string> { "cluster" })>
            </MetricsCounterGaugeSumView>
            <MetircsHistogramSumView AllMetrics="@AllMetrics" MetricName="etcd_lease_object_counts" Title=@L["Object Count"] CalcField="count"></MetircsHistogramSumView>

            <MetricsCounterGaugeSumView AllMetrics="@AllMetrics" Title=@L["Request Total"]
                                        MetricName="etcd_requests_total"
                                        MultipleGroupBy="@(new List<string> { "operation", "type" })">
            </MetricsCounterGaugeSumView>

            <MetircsHistogramTotalAvgView AllMetrics="@AllMetrics"
                                          Title=@L["Request Latency (avg)"]
                                          MetricName="etcd_request_duration_seconds"
                                          MultipleGroupBy="@(new List<string> { "operation", "type" })"
                                          Unit="seconds">
            </MetircsHistogramTotalAvgView>

        </TabPane>
        <TabPane Key="ApiServer" Tab=@L["API Server"]>
            <MetricsCounterGaugeSumView AllMetrics="@AllMetrics" Title=@L["Auth Counts"] MetricName="authentication_attempts"> </MetricsCounterGaugeSumView>
            <MetircsHistogramTotalAvgView AllMetrics="@AllMetrics" Title=@L["Auth Latency"]
                                          MetricName="authentication_duration_seconds"
                                          Unit="seconds">
            </MetircsHistogramTotalAvgView>
            <MetircsHistogramTotalAvgView AllMetrics="@AllMetrics" Title=@L["Request Latency"]
                                          MetricName="apiserver_request_duration_seconds" Unit="seconds"
                                          MultipleGroupBy="@(new List<string> { "component", "verb", "group", "resource", "subresource", "scope" })">
            </MetircsHistogramTotalAvgView>
            <MetircsHistogramSumView AllMetrics="@AllMetrics" MetricName="apiserver_response_sizes" Title=@L["Response Size (total)"] CalcField="sum" Unit="bytes"></MetircsHistogramSumView>
            <MetircsHistogramTotalAvgView AllMetrics="@AllMetrics" Title=@L["Response Size"]
                                          MetricName="apiserver_response_sizes" Unit="bytes"
                                          MultipleGroupBy="@(new List<string> { "component", "verb", "group", "resource", "subresource", "scope" })">
            </MetircsHistogramTotalAvgView>


            <MetricsCounterGaugeSumView AllMetrics="@AllMetrics" Title=@($"{L["Request"]} {L["InFlight"]}")
                                        MetricName="apiserver_current_inflight_requests"
                                        MultipleGroupBy="@(new List<string> { "request_kind" })">
            </MetricsCounterGaugeSumView>
            <MetricsCounterGaugeSumView AllMetrics="@AllMetrics" Title=@($"{L["Request"]} {L["InQueue"]}")
                                        MetricName="apiserver_current_inqueue_requests"
                                        MultipleGroupBy="@(new List<string> { "request_kind" })">
            </MetricsCounterGaugeSumView>
            <MetricsCounterGaugeSumView AllMetrics="@AllMetrics" Title=@($"{L["Workqueue"]} {L["Added"]}")
                                        MetricName="workqueue_adds_total"
                                        MultipleGroupBy="@(new List<string> { "name" })">
            </MetricsCounterGaugeSumView>
            <MetricsCounterGaugeSumView AllMetrics="@AllMetrics" Title=@($"{L["Workqueue"]} {L["Retries"]}")
                                        MetricName="workqueue_retries_total"
                                        MultipleGroupBy="@(new List<string> { "name" })">
            </MetricsCounterGaugeSumView>
            <MetricsCounterGaugeSumView AllMetrics="@AllMetrics" Title=@($"{L["Flowcontrol"]} {L["InQueue"]}")
                                        MetricName="apiserver_flowcontrol_current_inqueue_requests"
                                        MultipleGroupBy="@(new List<string> { "flow_schema", "priority_level" })">
            </MetricsCounterGaugeSumView>
            <MetricsCounterGaugeSumView AllMetrics="@AllMetrics" Title=@($"{L["Flowcontrol"]} {L["Executing"]}")
                                        MetricName="apiserver_flowcontrol_current_executing_requests"
                                        MultipleGroupBy="@(new List<string> { "flow_schema", "priority_level" })">
            </MetricsCounterGaugeSumView>
            <MetricsCounterGaugeSumView AllMetrics="@AllMetrics" Title=@L["Request Total"]
                                        MetricName="apiserver_request_total"
                                        MultipleGroupBy="@(new List<string> { "component", "verb", "group", "code", "resource", "subresource", "scope" })">
            </MetricsCounterGaugeSumView>


            <MetircsHistogramTotalAvgView AllMetrics="@AllMetrics" Title=@L["Request Sli Latency (avg)"]
                                          MetricName="apiserver_request_sli_duration_seconds" Unit="seconds"
                                          MultipleGroupBy="@(new List<string> { "component", "verb", "group", "resource", "subresource", "scope" })">
            </MetircsHistogramTotalAvgView>

        </TabPane>
    }


</Tabs >
